<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
   +function(){
       var a;//undefined
       function foo(){
           console.log(a)
       }

       foo();  //undefined
       a = 10;
       foo();  //10
   }()
    console.log(a);//报错了
</script>
</body>
</html>